package com.yuyou.fn.platform.service.impl;

import com.github.wens.framework.service.impl.SuperServiceImpl;
import com.github.wens.mybatisplus.examples.Example;
import com.yuyou.fn.platform.entity.OpenAuth;
import com.yuyou.fn.platform.mapper.OpenAuthMapper;
import com.yuyou.fn.platform.service.IOpenAuthService;
import org.springframework.stereotype.Service;

/**
 *
 * OpenAuth 表数据服务层接口实现类
 *
 */
@Service
public class OpenAuthServiceImpl extends SuperServiceImpl<OpenAuthMapper, OpenAuth,Long> implements IOpenAuthService {


    //@Cacheable("cacheOfAuth")
    @Override
    public boolean auth(String appId, String secretKey) {
        Example<OpenAuth> example = OpenAuth.createExample();
        example.createCriteria().andEqualTo("appId" , appId).andEqualTo("secretKey" , secretKey );
        OpenAuth openAuth = findOneByExample(example);
        return openAuth != null ? true : false ;
    }

    @Override
    public String findSecretKeyForAppId(String appId) {
        Example<OpenAuth> example = OpenAuth.createExample();
        example.createCriteria().andEqualTo("appId" , appId);
        OpenAuth openAuth = findOneByExample(example);
        return openAuth == null ? null : openAuth.getSecretKey() ;
    }
}